﻿@model  SDF.Plugin.Misc.DynamicEntity.Models.DynamicEntityItemModel
@{
    Layout = "~/Administration/Views/Shared/_AdminPopupLayout.cshtml";
    //page title
    ViewBag.Title = T("Plugins.Misc.DynamicEntity.EditField").Text;
}


@if (ViewBag.CloseModal != null)
{
    <Text>
    <script>
        //调用父页面方式关闭模态窗体
        window.parent.hideModal();
    </script>
    </Text>
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="content-header clearfix">
        <h1 class="pull-left">
            @Model.Header.Name
            <small>
                <i class="fa fa-arrow-circle-left"></i>
                @Html.ActionLink(T("Plugins.Misc.DynamicEntity.BackToEntity").Text, "EditHeader", new { id = Model.Header.Id })
            </small>
        </h1>
        <div class="pull-right">
            <button type="submit" name="save" class="btn bg-blue">
                <i class="fa fa-floppy-o"></i>
                @T("Admin.Common.Save")
            </button>
        </div>
    </div>

    <div id="div_partial">
        @Html.Partial("~/Plugins/SDF.Plugin.Misc.DynamicEntity/Views/DynamicEntity/_CreateOrUpdateItem.cshtml", Model)
    </div>
}
<script>
    //动态设置父iframe高度
    var oldHeight = -1;

    function setParentIframeHeight() {
        try {
            var formHeight = $("body").height();

            if (formHeight != oldHeight) {
                var parent = $(window.parent.document);
                parent.find("iframe").css("height", formHeight);

                oldHeight = formHeight;
            }
        } catch (e) {

        }
    }

    $(function () {
        if (window.parent) {
            setParentIframeHeight();
        }
        setInterval("setParentIframeHeight()", 500);
    })
</script>